
package controllers;

import java.lang.reflect.Method;

import play.Logger;
import play.mvc.Content;
import play.mvc.Result;

/**
 * 
 * @author laurent@opprecht.info
 */
public class Test extends Application {

    public static Result index(final String file, final String format) {
        if (format == null) {
            return notFound();
        }
        if (!format.equals("xml")) {
            return notFound();
        }

        try {
            @SuppressWarnings("rawtypes")
            Class cls = Class.forName("views.xml.test." + file);
            @SuppressWarnings("unchecked")
            Method method = cls.getMethod("render", String.class);
            String base = controllers.routes.Test.index("", "").absoluteURL(request());
            Object o = method.invoke(null, base);
            return ok((Content) o);
        } catch (Exception ex) {
            Logger.error("not found", ex);
            return notFound();
        }

    }
}
